package org.linlinjava.litemall.admin.controller.giftcards;

import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.service.LitemallGiftCardUserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户日志管理礼品卡控制器
 *
 * @author yliyun
 * @description：用户充值消费日志
 * @date 2022/09/14
 */
@RestController
@RequestMapping("admin/giftcardlog")
public class AdminGiftCardUserLogController {
    /**
     * litemall礼品卡用户日志服务
     */
    @Autowired
    private LitemallGiftCardUserLogService litemallGiftCardUserLogService;

    /**
     * 列表
     *
     * @param userName 用户名
     * @param type     类型
     * @param page     页面
     * @param limit    限制
     * @param sort     排序
     * @param order    订单
     * @return {@link Object}
     */
    @GetMapping("/list")
    @LogAnno
    public Object list(String userName, Byte type,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "desc") String order){
        return ResponseUtil.okList(litemallGiftCardUserLogService.querySelective(userName, type, page, limit, sort, order));
    }
}
